package cn.xgj.sfzy.service.impl;

import cn.xgj.sfzy.entity.*;
import cn.xgj.sfzy.mapper.ConsultMapper;
import cn.xgj.sfzy.mapper.CourseReplyMapper;
import cn.xgj.sfzy.mapper.MentalTestMapper;
import cn.xgj.sfzy.mapper.MyAssessmentMapper;
import cn.xgj.sfzy.service.MyAssessmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName MyAssessmentServiceImpl
 * @Description TODO
 * @Author furuyue
 * @Date 2024年10月28日 19:20
 * @Version 1.0
 */

@Service
public class MyAssessmentServiceImpl implements MyAssessmentService {

    @Autowired
    private MyAssessmentMapper myAssessmentMapper;
    @Autowired
    private MentalTestMapper mentalTestMapper;


    @Override
    public List<MyAssessment> findByUSerId(Long userId) {

        List<MyAssessment> list = myAssessmentMapper.findByUserId(userId);
        for(MyAssessment a :list){
            Long mentaltestId = a.getMentalTestId();
            MentalTest mentalTest = mentalTestMapper.findById(mentaltestId);
            a.setMentalTest(mentalTest);
        }
        return list;
    }

}
